package fr.afcepf.al22.qualite.data;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;

import javax.sql.DataSource;
/**
 * 
 * @author Stagiaire
 *
 */
public class Al22DataSource implements DataSource {
	/**
	 *
	 */
	private static String url;
	/**
	 *
	 */
	private static String driver;
	/**
	 *
	 */
	private static String login;
	/**
	 *
	 */
	private static String pass;
	static {
		Properties props = new Properties();
		try {
			InputStream is = Thread.currentThread().
					getContextClassLoader().
					getResourceAsStream("al22.properties");
			props.load(is);
			url = props.getProperty("url");
			login = props.getProperty("login");
			pass = props.getProperty("pass");
			driver = props.getProperty("driver");
			Class.forName(driver);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	@Override
	public PrintWriter getLogWriter() throws SQLException {
		return null;
	}

	@Override
	public int getLoginTimeout() throws SQLException {
		return 0;
	}

	@Override
	public Logger getParentLogger() throws SQLFeatureNotSupportedException {
		return null;
	}

	@Override
	public void setLogWriter(PrintWriter arg0) throws SQLException {

	}

	@Override
	public void setLoginTimeout(int arg0) throws SQLException {

	}

	@Override
	public boolean isWrapperFor(Class<?> arg0) throws SQLException {
		return false;
	}

	@Override
	public <T> T unwrap(Class<T> arg0) throws SQLException {
		return null;
	}

	@Override
	public Connection getConnection() throws SQLException {
		Connection cnx = null;
		cnx = DriverManager.getConnection(url, login, pass);
		return cnx;
	}

	@Override
	public Connection getConnection(String arg0, String arg1)
			throws SQLException {
		return null;
	}

}
